package com.dqhl.business.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.dqhl.business.R;
import com.dqhl.business.util.Config;
import com.dqhl.business.util.ScreenUtils;
import com.dqhl.business.util.ViewHolder;

import org.xutils.x;

import java.util.List;

/**
 * Created by mac on 16/11/8.
 */
public class GoodsDetailPicGridAdapter extends BaseAdapter {

    private Context context;
    private LayoutInflater inflater;
    private List<String> picList;

    public GoodsDetailPicGridAdapter(Context context, List<String> picList) {
        this.context = context;
        this.picList = picList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return picList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_goods_detail_pic, parent, false);
        }
        ImageView iv_pic = ViewHolder.get(convertView, R.id.iv_pic);
        int width = ScreenUtils.getScreenWidth(context) / 4;
        iv_pic.setMaxWidth(width);
        x.image().bind(iv_pic, Config.img_url + picList.get(position));
        return convertView;
    }
}
